package com.vf.admin.client.service.impl;

import com.vf.admin.client.dao.AgentUserCollectionDao;
import com.vf.admin.client.dao.AppUserCollectionDao;
import com.vf.admin.client.service.AgentUserCollectionService;
import com.vf.admin.client.service.AppUserCollectionService;
import com.vf.admin.miaodong.entity.AgentUserCollection;
import com.vf.admin.miaodong.entity.AppUserCollection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AgentUserCollectionServiceImpl implements AgentUserCollectionService {

    @Autowired
    AgentUserCollectionDao agentUserCollectionDao;

    @Override
    public void saveOrUpdate(AgentUserCollection params) {
        agentUserCollectionDao.saveOrUpdate(params);
    }

    @Override
    public AgentUserCollection findByUserId(Integer userId) {
        return agentUserCollectionDao.findByUserId(userId);
    }

    @Override
    public AgentUserCollection findByUserIdOrNULL(Integer userId) {
        AgentUserCollection collection = agentUserCollectionDao.findByUserId(userId);
        if(collection == null) {
            collection= new AgentUserCollection();
            collection.setAgentUserId(userId);
            collection.setBankcard("");
            collection.setBankcardname("");
            collection.setAliphonenum("");
            collection.setAliname("");
        }
        return collection;
    }
}
